// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.common;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class Threads {
  public static void waitOn(Object mutex) {
    try {
      mutex.wait();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }

  public static void notifyOn(Object mutex) {
    mutex.notify();
  }

  public static void notifyAllOn(Object mutex) {
    mutex.notifyAll();
  }
  
  public static void synchronizedWaitOn(Object mutex) {
    synchronized (mutex) {
      waitOn(mutex);
    }
  }
  
  public static void sleep(long millis) {
    try {
      Thread.sleep(millis);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
}
